<?php
/**
 * Smart Library - Smart Framework
 * http://smart-framework.highet.eu
 *
 * @category   SmartL
 * @package    SmartL_Application
 * @subpackage Plugin
 * @copyright  Copyright (c) 2005-2008 Smart Framework team - Stepan Sindelar, Vojtech Vit
 * @license    http://www.opensource.org/licenses/bsd-license.php	New BSD License
 */

/**
 * Interface for extended plugin for SmartL_Application events. 
 * 
 * @package SmartL_Application
 * @subpackage Plugin
 */
interface SmartL_Application_Plugin_Interface {
	/**
	 * Called before loading application configuration.
	 *
	 * @return boolean False if the following event (and all pre-phase plugins) 
	 *                 should be skipped.
	 */
	public function preLoadApplicationConfiguration();
	/**
	 * Called after loading application configuration.
	 */
	public function postLoadApplicationConfiguration();
	
	/**
	 * Called before Zend_Controller_Front is set up.
	 *
	 * @return boolean False if the following event (and all pre-phase plugins) 
	 *                 should be skipped.
	 */
	public function preSetUpFrontController();
	/**
	 * Called after Zend_Controller_Front is set up.
	 */
	public function postSetUpFrontController();
	
	/**
	 * Called before languages are set up.
	 * Default language and browser language are added to "languages" array
	 * in this phase.
	 *  
	 * @return boolean False if the following event (and all pre-phase plugins) 
	 *                 should be skipped.
	 */
	public function preSetUpLanguages();
	/**
	 * Called after languages are set up.
	 */
	public function postSetUpLanguages();
	
	/**
	 * Called before opening db connections.
	 *
	 * @return array[string name] => string connectionString | boolean Additional 
	 *                 db connection strings or False if the following event 
	 *                 (and all pre-phase plugins) should be skipped.
	 */
	public function preOpenDbConnections();
	/**
	 * Called after opening db connections.
	 */
	public function postOpenDbConnections();
	
	/**
	 * Called before user authentication.
	 *
	 * @return boolean False if the following event (and all pre-phase plugins) 
	 *                 should be skipped.
	 */
	public function preAuthenticateUser();
	/**
	 * Called after user authentication.
	 */
	public function postAuthenticateUser();
	
	/**
	 * Called before user authorization. 
	 *
	 * @return boolean False if the following event (and all pre-phase plugins) 
	 *                 should be skipped.
	 */
	public function preAuthorizeUser();
	/**
	 * Called after user authorization. 
	 */
	public function postAuthorizeUser();
	
	/**
	 * Called before module initialization.
	 *
	 * @param string $moduleName Module name
	 * @return string|boolean False if the following event (and all pre-phase plugins) 
	 *                        should be skipped or string-name of new module to 
	 *                        be initialized. Make sure that this module exists.
	 */
	public function preInitModule($moduleName);
	/**
	 * Called after module initialization.
	 *
	 * From this point, module is accessible through SmartL_Application.
	 * 
	 * @param string $moduleName
	 * @return string|boolean False if the following event (and all pre-phase plugins) 
	 *                        should be skipped or string-name of new module to 
	 *                        be initialized. Make sure that this module exists.
	 */
	public function postInitModule();
	
	/**
	 * Called before loading module configuration.
	 *
	 * @return boolean False if the following event (and all other pre-phase plugins) 
	 *                 should be skipped.
	 */
	public function preLoadModuleConfiguration();
	/**
	 * Called after loading module configuration.
	 */
	public function postLoadModuleConfiguration();
	
	/**
	 * Called before logged user's preferences are set up.
	 *
	 * @return SmartL_Application_User_Proferences_Interface|boolean Instance of 
	 *     SmartL_Application_User_Proferences_Interface with new user's preferences 
	 *     or False if the following event (and all other pre-phase plugins) should 
	 *     be skipped.
	 */
	public function preSetUpUserPreferences();
	/** 
	 * Called before logged user's preferences are set up.
	 * 
	 * @param SmartL_Application_Login_UserPreferences_Interface $preferences Preferences
	 *    that were set up.
	 */
	public function postSetUpUserPreferences(SmartL_Application_Login_UserPreferences_Interface $preferences = null);
	
	/**
	 * Called before starting a layout.
	 * If the current template doesn't need a layout, it won't be started, but this
	 * method will be called anyway.
	 *
	 * @return boolean False if the following event (and all other pre-phase plugins) 
	 *                 should be skipped.
	 */
	public function preStartLayout();
	/**
	 * Called after starting a layout.
	 * 
	 * @param boolean $started True if layout was started.
	 */
	public function postStartLayout($started);
}


